
import { Quaternion, Vector3 } from 'three';
import AModelFmulaUtils from '../utils/AModelFmulaUtils';

import AluGeoUtil from "./utils/AluGeoUtil";
import { CreateMeta, HoleMeta } from '../meta/MetaClass';
import VectorUtils from '../utils/VectorUtils';

/** 圆弧倒角转角平板 网格*/
export default class RChamferCPGMY {

    /** 基准板 切向距离*/
    private _b_offX: number = 0;
    /** 活动板 切向距离*/
    private _l_offX: number = 0;
    /** 切点与宽的比例*/
    private _tr: number = 1;

    /** 圆弧的x轴点*/
    private _r_x = 50;
    /** 圆弧的y轴点*/
    private _r_y = 50;
    /** 底厚*/
    private _b_t = 6;


    /** 基准板 切向距离*/
    private b_b_offX: number = 0;
    /** 活动板 切向距离*/
    private b_l_offX: number = 0;

    /** 基准板 切向距离*/
    private b_b_b_offX: number = 0;
    /** 活动板 切向距离*/
    private l_b_l_offX: number = 0;


    private _vertices: Array<number>;
    get vertices() { return this._vertices; }

    private _indices: Array<number>;
    get indices() { return this._indices; }


    constructor(data: AIBasicParams) {
        this._vertices = [];
        this._indices = [];

        this.generate(data);
        this.setDuan(data);
    }

    private setDuan(data: AIBasicParams) {
        data["duan"] = [
            0, data.H, 0,
            data.yyL, data.H, 0,
            0, data.H, data.zyL
        ];
        data["zhong"] = {
            yyL: [
                {
                    pointer: [data.yyL, data.H, +data.BKH / 2],
                    center: [data.yyL / 2, data.H, +data.BKH / 2]
                },
            ],
            zyL: [
                {
                    pointer: [+data.BKH / 2, data.H, +data.zyL],
                    center: [+data.BKH / 2, data.H, +data.zyL / 2]
                },
            ]
        }
    }

    private generate(data: AIBasicParams) {

        let angle = +data.angle1;
        let b_w = +data.BKH;
        let l_w = +data.BKH;


        //转锐角？
        let mr = (-1 * angle) - (-90);

        let rr = mr / 180 * Math.PI;
        let tr = Math.abs(mr) == 90 ? 0 : Math.tan(rr);
        let cr = Math.cos(rr);

        //x /cr + h * tr
        this._b_offX = (Math.abs(mr) == 90 ? 0 : b_w / cr) + l_w * tr;
        this._l_offX = (Math.abs(mr) == 90 ? 0 : l_w / cr) + b_w * tr;

        this._tr = this._b_offX / b_w;


        let s = AluGeoUtil.getEquinox(this._r_x, this._r_y, +data.angle1);
        this.b_b_offX = s.x;
        this.b_l_offX = s.z;

        s = AluGeoUtil.getEquinox(b_w - this._r_x, l_w - this._r_y, +data.angle1);
        this.b_b_b_offX = s.x;
        this.l_b_l_offX = s.z;


        this._basic(data);
        this._active(data);

        this._rad(data);
    }


    private _basic(data: AIBasicParams) {
        //顶板
        this.b_top(data);

        //光面板
        this.b_plank(data);

        //两侧板
        this.b_plank_r(data);

        //底板
        this.b_bottom(data);
    }


    private _active(data: AIBasicParams) {
        //顶板
        this.l_top(data);

        //光面板
        this.l_plank(data);

        // //两侧板
        this.l_plank_r(data);

        // //底板
        this.l_bottom(data);

    }

    /** 顶板*/
    private b_top(data: AIBasicParams) {

        let l = +data.BKH, w = +data.yyL, t = +data.fbH;
        let offsetY = +data.H;


        let back = [
            0, 0, 0, w, 0, 0, w, l, 0, this._b_offX, l, 0,
        ];

        let front = [
            0, 0, t, w, 0, t, w, l, t, this._b_offX, l, t,
        ];

        // data.p_syykw = data["o_p_syykw"];

        let holes = AModelFmulaUtils.getHolesbyExpress(data.p_syykw, w);
        let filterHole = AluGeoUtil.filterHoleLess(this._b_offX + (+data.BKDia * 0.5), holes);
        holes = AModelFmulaUtils.getHolesbyExpress(data.p_syykw, w, 2, data, "p_syykw", Math.abs(filterHole.length - holes.length));


        let h = new HoleMeta(+data.BKDia * 0.5, l - +data.BKKJMDis, holes, "x");
        let c = new CreateMeta(t, front, back, h);
        let r = AluGeoUtil.createBoardWithHole(c);

        let q = new Quaternion();
        q.setFromAxisAngle(new Vector3(1, 0, 0), Math.PI * 0.5);
        for (let i: number = 0; i < r.vertices.length; i += 3) {
            VectorUtils.assistVector3.set(r.vertices[i], r.vertices[i + 1], r.vertices[i + 2]);
            VectorUtils.assistVector3.applyQuaternion(q);

            r.vertices[i] = VectorUtils.assistVector3.x;
            r.vertices[i + 1] = VectorUtils.assistVector3.y + offsetY;
            r.vertices[i + 2] = VectorUtils.assistVector3.z;
        }

        let len = this._vertices.length / 3;
        this._indices.push(...r.indices.map((v) => { return v + len }));
        this._vertices.push(...r.vertices);
    }


    /** 顶板*/
    private l_top(data: AIBasicParams) {

        let l = +data.BKH, w = +data.zyL, t = +data.fbH;
        let offsetY = +data.H;

        let back = [
            this._l_offX, 0, 0, w, 0, 0, w, l, 0, 0, l, 0,
        ];

        let front = [
            this._l_offX, 0, t, w, 0, t, w, l, t, 0, l, t,
        ];

        // data.p_szykw = data["o_p_szykw"];

        let holes = AModelFmulaUtils.getHolesbyExpress(data.p_szykw, w);
        let filterHole = AluGeoUtil.filterHoleLess(this._l_offX + (+data.BKDia * 0.5), holes);
        holes = AModelFmulaUtils.getHolesbyExpress(data.p_szykw, w, 2, data, "p_szykw", Math.abs(filterHole.length - holes.length));


        let h = new HoleMeta(+data.BKDia * 0.5, +data.BKKJMDis, holes, "x");
        let c = new CreateMeta(t, front, back, h);
        let r = AluGeoUtil.createBoardWithHole(c);

        let q = new Quaternion();
        q.setFromAxisAngle(new Vector3(1, 0, 0), Math.PI * 0.5);

        let ar = (-1 * (+data.angle1)) / 180 * Math.PI;
        let qy = new Quaternion();
        qy.setFromAxisAngle(new Vector3(0, 1, 0), ar);



        for (let i: number = 0; i < r.vertices.length; i += 3) {
            VectorUtils.assistVector3.set(r.vertices[i], r.vertices[i + 1], r.vertices[i + 2]);
            VectorUtils.assistVector3.applyQuaternion(q);
            VectorUtils.assistVector3.set(VectorUtils.assistVector3.x, VectorUtils.assistVector3.y, VectorUtils.assistVector3.z - l).applyQuaternion(qy);

            r.vertices[i] = VectorUtils.assistVector3.x;
            r.vertices[i + 1] = VectorUtils.assistVector3.y + offsetY;
            r.vertices[i + 2] = VectorUtils.assistVector3.z;
        }

        let len = this._vertices.length / 3;
        this._indices.push(...r.indices.map((v) => { return v + len }));
        this._vertices.push(...r.vertices);
    }




    /** 光面板*/
    private b_plank(data: AIBasicParams) {
        // DJXQW

        let l = +data.H - 50, w = +data.yyL, t = +data.GMT;
        let offsetY = 50;

        let s = AluGeoUtil.getEquinox(t, t, +data.angle1).x;


        let back = [
            0, 0, 0, w, 0, 0, w, l, 0, 0, l, 0,
        ];

        let front = [
            s, 0, t, w, 0, t, w, l, t, s, l, t,
        ];


        // let h = new HoleMeta(data.BKDia * 0.5, w - bj, hole);
        let c = new CreateMeta(t, front, back, null);
        let r = AluGeoUtil.createBoardWithHole(c);

        // let q = new Quaternion();
        // q.setFromAxisAngle(new Vector3(1, 0, 0), Math.PI * 0.5);
        for (let i: number = 0; i < r.vertices.length; i += 3) {
            VectorUtils.assistVector3.set(r.vertices[i], r.vertices[i + 1], r.vertices[i + 2]);
            // VectorUtils.assistVector3.applyQuaternion(q);

            // r.vertices[i] = VectorUtils.assistVector3.x;
            r.vertices[i + 1] = VectorUtils.assistVector3.y + offsetY;
            // r.vertices[i + 2] = VectorUtils.assistVector3.z;
        }

        let len = this._vertices.length / 3;
        this._indices.push(...r.indices.map((v) => { return v + len }));
        this._vertices.push(...r.vertices);
    }



    /** 光面板*/
    private l_plank(data: AIBasicParams) {
        // DJXQW

        let l = +data.H - 50, w = +data.zyL, t = +data.GMT;
        let offsetY = 50;

        let s = AluGeoUtil.getEquinox(t, t, +data.angle1).z;

        let back = [
            s, 0, 0, w, 0, 0, w, l, 0, s, l, 0,
        ];

        let front = [
            0, 0, t, w, 0, t, w, l, t, 0, l, t,
        ];


        // let h = new HoleMeta(data.BKDia * 0.5, w - bj, hole);
        let c = new CreateMeta(t, front, back, null);
        let r = AluGeoUtil.createBoardWithHole(c);

        let ar = (-1 * (+data.angle1)) / 180 * Math.PI;
        let qy = new Quaternion();
        qy.setFromAxisAngle(new Vector3(0, 1, 0), ar);

        for (let i: number = 0; i < r.vertices.length; i += 3) {
            VectorUtils.assistVector3.set(r.vertices[i], r.vertices[i + 1], r.vertices[i + 2] - t);
            VectorUtils.assistVector3.applyQuaternion(qy);

            r.vertices[i] = VectorUtils.assistVector3.x;
            r.vertices[i + 1] = VectorUtils.assistVector3.y + offsetY;
            r.vertices[i + 2] = VectorUtils.assistVector3.z;
        }

        let len = this._vertices.length / 3;
        this._indices.push(...r.indices.map((v) => { return v + len }));
        this._vertices.push(...r.vertices);
    }




    /** 右侧板 */
    private b_plank_r(data: AIBasicParams) {
        let l = +data.H, sl = 50, sw = 50, w = +data.BKH, t = +data.bkT;
        let offsetX = +data.yyL;

        let back = [
            sw, 0, 0, w, 0, 0, w, l, 0, 0, l, 0, 0, sl, 0
        ];

        let front = [
            sw, 0, t, w, 0, t, w, l, t, 0, l, t, 0, sl, t
        ];

        // data.p_ykkw = data["o_p_ykkw"];

        // let holes = AModelFmulaUtils.getHolesbyExpress(data.p_ykkw, l);
        // let filterHole = AluGeoUtil.filterHole(l - sl - (+data.BKDia * 0.5), holes);
        let holes = AModelFmulaUtils.getHolesbyExpress(data.p_ykkw, l, 2, data, "p_ykkw");

        let h = new HoleMeta(data.BKDia * 0.5, w - (+data.BKKJMDis), AluGeoUtil.reverseHole(l, holes));

        // let h = new HoleMeta(data.BKDia * 0.5, w - bj, hole);
        let c = new CreateMeta(t, front, back, h);
        let r = AluGeoUtil.createBoardWithHole(c);

        let q = new Quaternion();
        q.setFromAxisAngle(new Vector3(0, 1, 0), Math.PI * -0.5);
        for (let i: number = 0; i < r.vertices.length; i += 3) {
            VectorUtils.assistVector3.set(r.vertices[i], r.vertices[i + 1], r.vertices[i + 2]);
            VectorUtils.assistVector3.applyQuaternion(q);

            r.vertices[i] = VectorUtils.assistVector3.x + offsetX;
            r.vertices[i + 1] = VectorUtils.assistVector3.y;
            r.vertices[i + 2] = VectorUtils.assistVector3.z;
        }

        let len = this._vertices.length / 3;
        this._indices.push(...r.indices.map((v) => { return v + len }));
        this._vertices.push(...r.vertices);
    }


    /** 右侧板 */
    private l_plank_r(data: AIBasicParams) {
        let l = +data.H, sl = 50, sw = 50, w = +data.BKH, t = +data.bkT;
        let offsetX = +data.zyL - t;

        let back = [
            sw, 0, 0, w, 0, 0, w, l, 0, 0, l, 0, 0, sl, 0
        ];

        let front = [
            sw, 0, t, w, 0, t, w, l, t, 0, l, t, 0, sl, t
        ];

        // data.p_zkkw = data["o_p_zkkw"];

        // let holes = AModelFmulaUtils.getHolesbyExpress(data.p_zkkw, l);
        // let filterHole = AluGeoUtil.filterHole(l - sl - (+data.BKDia * 0.5), holes);
        let holes = AModelFmulaUtils.getHolesbyExpress(data.p_zkkw, l, 2, data, "p_zkkw");

        let h = new HoleMeta(data.BKDia * 0.5, w - (+data.BKKJMDis), AluGeoUtil.reverseHole(l, holes));

        // let h = new HoleMeta(data.BKDia * 0.5, w - bj, hole);
        let c = new CreateMeta(t, front, back, h);
        let r = AluGeoUtil.createBoardWithHole(c);

        let q = new Quaternion();
        q.setFromAxisAngle(new Vector3(0, 1, 0), Math.PI * 0.5);

        let ar = (-1 * (+data.angle1)) / 180 * Math.PI;
        let qy = new Quaternion();
        qy.setFromAxisAngle(new Vector3(0, 1, 0), ar);

        for (let i: number = 0; i < r.vertices.length; i += 3) {
            VectorUtils.assistVector3.set(r.vertices[i], r.vertices[i + 1], r.vertices[i + 2]);
            VectorUtils.assistVector3.applyQuaternion(q);

            VectorUtils.assistVector3.set(VectorUtils.assistVector3.x + offsetX, VectorUtils.assistVector3.y, VectorUtils.assistVector3.z).applyQuaternion(qy);


            r.vertices[i] = VectorUtils.assistVector3.x;
            r.vertices[i + 1] = VectorUtils.assistVector3.y;
            r.vertices[i + 2] = VectorUtils.assistVector3.z;
        }

        let len = this._vertices.length / 3;
        this._indices.push(...r.indices.map((v) => { return v + len }));
        this._vertices.push(...r.vertices);
    }


    /** 底板*/
    private b_bottom(data: AIBasicParams) {
        let l = +data.BKH - 50, w = (+data.yyL) - this.b_b_offX, t = this._b_t;
        let offsetZ = 50;

        let back = [
            0, 0, 0, w, 0, 0, w, l, 0, this.b_b_b_offX, l, 0,
        ];

        let front = [
            0, 0, t, w, 0, t, w, l, t, this.b_b_b_offX, l, t,
        ];


        // let h = new HoleMeta(data.BKDia * 0.5, w - bj, hole);
        let c = new CreateMeta(t, front, back, null);
        let r = AluGeoUtil.createBoardWithHole(c);

        let q = new Quaternion();
        q.setFromAxisAngle(new Vector3(1, 0, 0), Math.PI * 0.5);
        for (let i: number = 0; i < r.vertices.length; i += 3) {
            VectorUtils.assistVector3.set(r.vertices[i], r.vertices[i + 1], r.vertices[i + 2]);
            VectorUtils.assistVector3.applyQuaternion(q);

            r.vertices[i] = VectorUtils.assistVector3.x + this.b_b_offX;
            r.vertices[i + 1] = VectorUtils.assistVector3.y + t;
            r.vertices[i + 2] = VectorUtils.assistVector3.z + offsetZ;
        }

        let len = this._vertices.length / 3;
        this._indices.push(...r.indices.map((v) => { return v + len }));
        this._vertices.push(...r.vertices);
    }


    /** 底板*/
    private l_bottom(data: AIBasicParams) {
        let l = +data.BKH - 50, w = (+data.zyL) - this.b_l_offX, t = this._b_t;
        let offsetZ = 50;

        let back = [
            this.l_b_l_offX, 0, 0, w, 0, 0, w, l, 0, 0, l, 0,
        ];

        let front = [
            this.l_b_l_offX, 0, t, w, 0, t, w, l, t, 0, l, t,
        ];


        // let h = new HoleMeta(data.BKDia * 0.5, w - bj, hole);
        let c = new CreateMeta(t, front, back, null);
        let r = AluGeoUtil.createBoardWithHole(c);

        let q = new Quaternion();
        q.setFromAxisAngle(new Vector3(1, 0, 0), Math.PI * 0.5);

        let ar = (-1 * (+data.angle1)) / 180 * Math.PI;
        let qy = new Quaternion();
        qy.setFromAxisAngle(new Vector3(0, 1, 0), ar);

        for (let i: number = 0; i < r.vertices.length; i += 3) {
            VectorUtils.assistVector3.set(r.vertices[i], r.vertices[i + 1], r.vertices[i + 2]);
            VectorUtils.assistVector3.applyQuaternion(q);

            r.vertices[i] = VectorUtils.assistVector3.x + this.b_l_offX;
            r.vertices[i + 1] = VectorUtils.assistVector3.y + t;
            r.vertices[i + 2] = VectorUtils.assistVector3.z - +data.BKH;


            VectorUtils.assistVector3.set(r.vertices[i], r.vertices[i + 1], r.vertices[i + 2]).applyQuaternion(qy);
            r.vertices[i] = VectorUtils.assistVector3.x;
            r.vertices[i + 1] = VectorUtils.assistVector3.y;
            r.vertices[i + 2] = VectorUtils.assistVector3.z;
        }

        let len = this._vertices.length / 3;
        this._indices.push(...r.indices.map((v) => { return v + len }));
        this._vertices.push(...r.vertices);
    }













    ///////弧板
    /** 弧板的处理*/
    private _rad(data: AIBasicParams) {
        let x = 50, y = 50, t = +data.GMT, r = +data.arcR;

        //圆心信息
        let c = AluGeoUtil.toCircleCenter(x, y, r, t);

        //外弧
        let a = AluGeoUtil.circlePath(c.center.x, c.center.y, r, c.o_arc_deg, c.o_arc_r_deg, 128);

        //内弧
        let b = AluGeoUtil.circlePath(c.center.x, c.center.y, c.inner_arc_radius, c.i_arc_deg, c.i_arc_r_deg, 128);


        let ar = (-1 * (+data.angle1)) / 180 * Math.PI;
        let qy = new Quaternion();
        qy.setFromAxisAngle(new Vector3(0, 1, 0), ar);

        this.b_ellipse(a, b, +data.yyL, x, y);
        this.l_ellipse(a, b, +data.zyL, x, y, qy);
    }


    /** 左侧的弧板处理*/
    private l_ellipse(op: Array<number>, ip: Array<number>, l: number, sw: number, sl: number, qy: Quaternion) {
        let ps = [...op];
        let ips = [...ip];

        let vec = [];
        let indics = [];

        /** 先移动路劲*/
        let movePath = (path: Array<number>, index: number) => {
            let x = path[index];
            let y = path[index + 1];
            let z = path[index + 2];

            x -= sw;

            //绕x 180 z=y y=-z
            y = -y;


            // //绕y 90 x = z, z = -x;
            let t = z;
            z = -x;
            x = t;

            y += sl;

            // z -= sw;
            // 绕xoy 镜像 z = -z
            z = -z;

            path[index] = x + l;
            path[index + 1] = y;
            path[index + 2] = z;
        }

        //曲面
        let triangleCur = (path: Array<number>, iPath: Array<number>, index: number) => {

            if (index == 0) {
                return;
            }

            let last = index - 3;

            //外曲面
            let a1 = [path[last], path[last + 1], path[last + 2]];
            let a2 = [path[index], path[index + 1], path[index + 2]];

            let lxx = path[last + 2] * this._tr;
            let xx = path[index + 2] * this._tr;

            let b1 = [-lxx, path[last + 1], path[last + 2]];
            let b2 = [-xx, path[index + 1], path[index + 2]];




            let no = vec.length / 3;
            indics.push(no, no + 2, no + 3, no + 3, no + 1, no);
            vec.push(...a1, ...a2, ...b1, ...b2);



            //内曲面
            let aa1 = [iPath[last], iPath[last + 1], iPath[last + 2]];
            let aa2 = [iPath[index], iPath[index + 1], iPath[index + 2]];

            let lxxx = iPath[last + 2] * this._tr;
            let xxx = iPath[index + 2] * this._tr;

            let bb1 = [-lxxx, iPath[last + 1], iPath[last + 2]];
            let bb2 = [-xxx, iPath[index + 1], iPath[index + 2]];



            no = vec.length / 3;
            indics.push(no, no + 1, no + 3, no + 3, no + 2, no);
            vec.push(...aa1, ...aa2, ...bb1, ...bb2);
        }


        //侧面
        let triangle = (path: Array<number>, iPath: Array<number>, index: number) => {

            if (index == 0) {
                return;
            }

            //下一个点
            let last = index - 3;

            let a1 = [path[last], path[last + 1], path[last + 2]];
            let a2 = [path[index], path[index + 1], path[index + 2]];

            let b1 = [iPath[last], iPath[last + 1], iPath[last + 2]];
            let b2 = [iPath[index], iPath[index + 1], iPath[index + 2]];

            let no = vec.length / 3;
            indics.push(no, no + 1, no + 2, no + 2, no + 1, no + 3);
            vec.push(...a1, ...a2, ...b1, ...b2);
        }


        for (let i: number = 0; i < ps.length; i += 3) {
            movePath(ps, i);
            movePath(ips, i);

            //组面
            triangleCur(ps, ips, i);
            triangle(ps, ips, i);
        }


        for (let j: number = 0; j < vec.length; j += 3) {
            let x = vec[j];
            let y = vec[j + 1];
            let z = vec[j + 2];

            VectorUtils.assistVector3.set(x, y, z).applyQuaternion(qy);

            vec[j] = VectorUtils.assistVector3.x;
            vec[j + 1] = VectorUtils.assistVector3.y;
            vec[j + 2] = VectorUtils.assistVector3.z;

        }


        let indics_num = this._vertices.length / 3;
        this._indices.push(...indics.map((v) => { return v + indics_num }));
        this._vertices.push(...vec);
    }


    /** 根据弧路径组面
     * op 外弧路径点
     * ip 内弧路径点
     * l 长
     * x 原始在x轴上的点
     * y 原始在y轴上的点
    */
    private b_ellipse(op: Array<number>, ip: Array<number>, l: number, sw: number, sl: number) {

        let ps = [...op];
        let ips = [...ip];

        /** 先移动路劲*/
        let movePath = (path: Array<number>, index: number) => {
            //先平移

            let x = path[index];
            let y = path[index + 1];
            let z = path[index + 2];

            x -= sw;

            //绕x 180 z=y y=-z
            y = -y;


            // //绕y 90 x = z, z = -x;
            let t = z;
            z = -x;
            x = t;

            y += sl;


            path[index] = x + l;
            path[index + 1] = y;
            path[index + 2] = z;
        }

        //曲面
        let triangleCur = (path: Array<number>, iPath: Array<number>, index: number) => {

            if (index == 0) {
                return;
            }

            let last = index - 3;

            //外曲面
            let a1 = [path[last], path[last + 1], path[last + 2]];
            let a2 = [path[index], path[index + 1], path[index + 2]];

            let lxx = path[last + 2] * this._tr;
            let xx = path[index + 2] * this._tr;

            let b1 = [lxx, path[last + 1], path[last + 2]];
            let b2 = [xx, path[index + 1], path[index + 2]];

            let no = this._vertices.length / 3;
            this._indices.push(no, no + 2, no + 3, no + 3, no + 1, no);
            this._vertices.push(...a1, ...a2, ...b1, ...b2);



            //内曲面
            let aa1 = [iPath[last], iPath[last + 1], iPath[last + 2]];
            let aa2 = [iPath[index], iPath[index + 1], iPath[index + 2]];

            let lxxx = iPath[last + 2] * this._tr;
            let xxx = iPath[index + 2] * this._tr;

            let bb1 = [lxxx, iPath[last + 1], iPath[last + 2]];
            let bb2 = [xxx, iPath[index + 1], iPath[index + 2]];
            no = this._vertices.length / 3;
            this._indices.push(no, no + 1, no + 3, no + 3, no + 2, no);
            this._vertices.push(...aa1, ...aa2, ...bb1, ...bb2);
        }


        //侧面
        let triangle = (path: Array<number>, iPath: Array<number>, index: number) => {

            if (index == 0) {
                return;
            }

            //下一个点
            let last = index - 3;

            let a1 = [path[last], path[last + 1], path[last + 2]];
            let a2 = [path[index], path[index + 1], path[index + 2]];

            let b1 = [iPath[last], iPath[last + 1], iPath[last + 2]];
            let b2 = [iPath[index], iPath[index + 1], iPath[index + 2]];

            let no = this._vertices.length / 3;
            this._indices.push(no, no + 1, no + 2, no + 2, no + 1, no + 3);
            this._vertices.push(...a1, ...a2, ...b1, ...b2);
        }


        for (let i: number = 0; i < ps.length; i += 3) {
            movePath(ps, i);
            movePath(ips, i);

            //组面
            triangleCur(ps, ips, i);
            triangle(ps, ips, i);
        }
    }

}